package cc.abanlee.framework.mybatis.config;

import cc.abanlee.framework.mybatis.core.interceptor.InsertInterceptor;
import cc.abanlee.framework.mybatis.core.interceptor.PrintSqlInterceptor;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.Properties;

/**
 * @author: create by
 * @version: v1.0
 * @description:
 * @date:2022/8/25
 */
@Configuration
@EnableConfigurationProperties({LiMybatisProperties.class})
public class LiMybatisAutoConfiguration {

    @Bean
    PrintSqlInterceptor printSqlInterceptor(LiMybatisProperties liMybatisProperties){
        return new PrintSqlInterceptor(liMybatisProperties);
    }

    @Bean
    InsertInterceptor insertInterceptor(){
        InsertInterceptor insertInterceptor = new InsertInterceptor();
        Properties properties = new Properties();
        properties.setProperty("createDate", "createDate");
        insertInterceptor.setProperties(properties);
        return insertInterceptor;
    }


//
//    @Bean
//    public ConfigurationCustomizer configurationCustomizer(){
//        return new ConfigurationCustomizer() {
//            @Override
//            public void customize(MybatisConfiguration configuration) {
//                InsertInterceptor insertInterceptor = new InsertInterceptor();
//                Properties properties = new Properties();
//                properties.setProperty("createDate", "createDate");
//                insertInterceptor.setProperties(properties);
//                configuration.addInterceptor(insertInterceptor);
//            }
//        };
//    }
}
